package cn.iocoder.yudao.module.promotion.framework;

import cn.iocoder.yudao.framework.datapermission.v1.UniDataPermissionRuleCustomizer;
import cn.iocoder.yudao.module.promotion.bargain.dal.dataobject.BargainActivityDO;
import cn.iocoder.yudao.module.promotion.bargain.dal.dataobject.BargainRecordDO;
import cn.iocoder.yudao.module.promotion.combination.dal.dataobject.CombinationActivityDO;
import cn.iocoder.yudao.module.promotion.combination.dal.dataobject.CombinationProductDO;
import cn.iocoder.yudao.module.promotion.combination.dal.dataobject.CombinationRecordDO;
import cn.iocoder.yudao.module.promotion.coupon.dal.dataobject.CouponRecordDO;
import cn.iocoder.yudao.module.promotion.coupon.dal.dataobject.CouponTemplateDO;
import cn.iocoder.yudao.module.promotion.discount.dal.dataobject.DiscountActivityDO;
import cn.iocoder.yudao.module.promotion.discount.dal.dataobject.DiscountProductDO;
import cn.iocoder.yudao.module.promotion.gift.pojo.po.GiftActivity;
import cn.iocoder.yudao.module.promotion.gift.pojo.po.GiftRecord;
import cn.iocoder.yudao.module.promotion.gift.pojo.po.GiftScanConfig;
import cn.iocoder.yudao.module.promotion.groupon.pojo.po.GrouponOrder;
import cn.iocoder.yudao.module.promotion.groupon.pojo.po.GrouponPackage;
import cn.iocoder.yudao.module.promotion.groupon.pojo.po.GrouponProduct;
import cn.iocoder.yudao.module.promotion.point.dal.dataobject.PointActivityDO;
import cn.iocoder.yudao.module.promotion.point.dal.dataobject.PointProductDO;
import cn.iocoder.yudao.module.promotion.redpacket.pojo.po.RedPacketActivity;
import cn.iocoder.yudao.module.promotion.redpacket.pojo.po.RedPacketConfig;
import cn.iocoder.yudao.module.promotion.redpacket.pojo.po.RedPacketRecord;
import cn.iocoder.yudao.module.promotion.redpacket.pojo.po.RedPacketUsed;
import cn.iocoder.yudao.module.promotion.reward.dal.dataobject.RewardActivityDO;
import cn.iocoder.yudao.module.promotion.seckill.dal.dataobject.SeckillActivityDO;
import cn.iocoder.yudao.module.promotion.seckill.dal.dataobject.SeckillProductDO;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * permission 组件的 Configuration
 */
@Configuration(proxyBeanMethods = false)
public class PromotionDataPermissionConfiguration {

    @Bean
    public UniDataPermissionRuleCustomizer promotionDataPermissionRuleCustomizer() {
        return rule -> {
            // shop 基于店铺的数据权限
            rule.addDataColumn(BargainActivityDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(BargainRecordDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(CombinationActivityDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(CombinationProductDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(CombinationRecordDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(CouponRecordDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(CouponTemplateDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(DiscountActivityDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(DiscountProductDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(PointActivityDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(PointProductDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(RewardActivityDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(SeckillActivityDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(SeckillProductDO.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(GiftActivity.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(GiftRecord.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(GiftScanConfig.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(GrouponPackage.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(GrouponProduct.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(GrouponOrder.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(RedPacketActivity.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(RedPacketRecord.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(RedPacketConfig.class, "shop_id"); // WHERE shop_id = ?
            rule.addDataColumn(RedPacketUsed.class, "shop_id"); // WHERE shop_id = ?
        };
    }

}
